<template>
	<view>
		<uni-nav-bar :fixed="true" :statusBar="true" :border="false" @click-right="openAdd">
			<!-- 左边 -->
			<block slot="left">
				<view class="nav-left">
					<view class="icon iconfont icon-qiandao"></view>
				</view>
			</block>
			<!-- 中间 -->
			<view class="nav-tab-bar u-f-ajc">
				<block v-for="(tab,index) in tabBars" :key="tab.id">
					<view class="u-f-ajc" :class="{'active': tabIndex == index }" @tap="changeTab(index)">
						{{tab.name}}
						<view v-if="tabIndex == index" class="nav-tab-bar-line"></view>
					</view>
				</block>
			</view>
			<!-- 右边 -->
			<block slot="right">
				<view class="nav-right u-f-ajc">
					<view class="icon iconfont icon-bianji1"></view>
				</view>
			</block>
		</uni-nav-bar>
	</view>
</template>

<script>
	import uniNavBar from "../../components/uni-nav-bar/uni-nav-bar";
	export default {
		props:{
			tabBars:Array,
			tabIndex:Number
		},
		components:{
			uniNavBar
		},
		methods:{
			changeTab(index){
				// this.tabIndex = index;
				this.$emit('chang-tab',index)
			},
			openAdd(){
				// 跳转发布页
				uni.navigateTo({
					url:"/pages/add-input/add-input"
				})
			}
		}
	}
</script>

<style scoped>
	.nav-right>view,.nav-left>view{
		font-size: 40upx;
	}
	.nav-left>view{
		color: #FF9619;
	}
	
	.nav-left{
		margin-left: 16upx;
	}
	.nav-right{
		width: 100%;
	}
	.nav-tab-bar{
		width: 100%;
		margin-left: -20upx;
		position: relative;
	}
	.nav-tab-bar>view{
		font-size: 35upx;
		padding: 0 15upx;
		font-weight: bold;
		color: #969696;
	}
	.active{
		color: #333333 !important;
	}
	.nav-tab-bar-line{
		position: absolute;
		bottom: 0upx;
		border-bottom: 5upx solid #FEDE33;
		border-top: 5upx solid #FEDE33;
		width: 70upx;
		border-radius: 20upx;
	}
	
	/* #ifdef MP-WEIXIN */
		.uni-status-bar{
			height: 0!important;
		}
	/* #endif */
</style>
